//
//  VipInfoMainView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/27.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VipInfoMainView.h"

@implementation VipInfoMainView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        /**
         背景
         */
        UIImageView *bgImageView = [[UIImageView alloc] init];
        bgImageView.image = [UIImage imageNamed:@"img_mbg"];
        [self addSubview:bgImageView];
        self.bgImageView = bgImageView;

//        /**
//         标题
//         */
//        UILabel *titleLabel = [[UILabel alloc] init];
//        titleLabel.text = @"会员详情";
//        titleLabel.font = [UIFont boldSystemFontOfSize:18];
//        titleLabel.textColor = CSWhiteColor;
//        [self addSubview:titleLabel];
//        self.titleLabel = titleLabel;
//
//        /**
//         返回按钮
//         */
//        UIButton *backBtn = [[UIButton alloc] init];
//        [backBtn setImage:@"icon_mback"];
//        [self addSubview:backBtn];
//        self.backBtn = backBtn;
//
//        /**
//         设置按钮
//         */
//        UIButton *setBtn = [[UIButton alloc] init];
//        [setBtn setImage:@"icon_mset"];
//        [self addSubview:setBtn];
//        self.setBtn = setBtn;
//
//        /**
//         详情按钮
//         */
//        UIButton *infoBtn = [[UIButton alloc] init];
//        [infoBtn setImage:@"icon_mmore"];
//        [self addSubview:infoBtn];
//        self.infoBtn = infoBtn;
        
        
        /**
         头像
         */
        UIImageView *headImageView = [[UIImageView alloc] init];
        headImageView.image = PlaceHold;
        headImageView.backgroundColor = CSRedColor;
        headImageView.contentMode = UIViewContentModeScaleAspectFill;
        headImageView.layer.masksToBounds = YES;
        headImageView.layer.cornerRadius = 30;
        [self addSubview:headImageView];
        self.headImageView = headImageView;
        
        
        /**
         昵称
         */
        UILabel *nickNameLabel = [[UILabel alloc] init];
        nickNameLabel.font = MidBigFont;
        nickNameLabel.textColor = CSColorFromRGB(0xffffff);
        nickNameLabel.text = @"暗暗";
        [self addSubview:nickNameLabel];
        self.nickNameLabel = nickNameLabel;
        
        /**
         性别
         */
        UIImageView *sexImage = [[UIImageView alloc] init];
        sexImage.image = [UIImage imageNamed:@"icon_female"];
        [self addSubview:sexImage];
        self.sexImage = sexImage;
        
        
        
        /**
         电话Label
         */
        UILabel *phoneLabel = [[UILabel alloc] init];
        phoneLabel.text = @"13152741472";
        phoneLabel.font = MidFont;
        phoneLabel.textColor = CSColorFromRGB(0x999999);
        [self addSubview:phoneLabel];
        self.phoneLabel = phoneLabel;
        
        /**
         年龄
         */
        UILabel *ageLabel = [[UILabel alloc] init];
        ageLabel.text = @"22岁";
        ageLabel.font = MidFont;
        ageLabel.textColor = CSColorFromRGB(0x999999);
        [self addSubview:ageLabel];
        self.ageLabel = ageLabel;
        
        /**
         电话
         */
        UIButton *phoneBtn = [[UIButton alloc] init];
        [phoneBtn setImage:@"icon_mphone"];
        [self addSubview:phoneBtn];
        self.phoneBtn = phoneBtn;
        
        /**
         短信
         */
        UIButton *msgBtn = [[UIButton alloc] init];
        [msgBtn setImage:@"icon_mmessage"];
        [self addSubview:msgBtn];
        self.msgBtn = msgBtn;
        
        /**
         基本信息
         */
        UIButton *btn1 = [[UIButton alloc] init];
        btn1.tag = 0;
        btn1.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 0);
        [btn1 setTitle:@"基本信息"];
        [btn1 setTitleColor:CSColorFromRGB(0xffffff)];
        [btn1 setSelectedTitleColor:CSColorFromRGB(0xbbbbbb)];
        btn1.titleLabel.font = MidBigFont;
        [self addSubview:btn1];
        self.btn1 = btn1;
        
        /**
         上课记录
         */
        UIButton *btn2 = [[UIButton alloc] init];
        btn2.tag = 1;
        btn2.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 0);
        [btn2 setTitle:@"上课记录"];
        [btn2 setTitleColor:CSColorFromRGB(0xffffff)];
        [btn2 setSelectedTitleColor:CSColorFromRGB(0xbbbbbb)];
        btn2.titleLabel.font = MidFont;
        [self addSubview:btn2];
        self.btn2 = btn2;
        
        /**
         跟进记录
         */
        UIButton *btn3 = [[UIButton alloc] init];
        btn3.tag = 2;
        btn3.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 0);
        [btn3 setTitle:@"跟进记录"];
        [btn3 setTitleColor:CSColorFromRGB(0xffffff)];
        [btn3 setSelectedTitleColor:CSColorFromRGB(0xbbbbbb)];
        btn3.titleLabel.font = MidFont;
        [self addSubview:btn3];
        self.btn3 = btn3;
        
        /**
         更多信息
         */
        UIButton *btn4 = [[UIButton alloc] init];
        btn4.tag = 3;
        btn4.contentEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 0);
        [btn4 setTitle:@"更多信息"];
        [btn4 setTitleColor:CSColorFromRGB(0xffffff)];
        [btn4 setSelectedTitleColor:CSColorFromRGB(0xbbbbbb)];
        btn4.titleLabel.font = MidFont;
        [self addSubview:btn4];
        self.btn4 = btn4;

        
        UIImageView *sanJiaoImageView = [[UIImageView alloc] init];
        sanJiaoImageView.image = [UIImage imageNamed:@"icon_mjiao"];
        [self addSubview:sanJiaoImageView];
        self.sanJiaoImageView = sanJiaoImageView;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    /**
     背景
     */
    [self.bgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.width.mas_equalTo(self);
        
        make.bottom.mas_equalTo(self).offset(10);
    }];
    
//    /**
//     标题
//     */
//    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//        make.top.mas_equalTo(self).offset(30);
//
//        make.centerX.mas_equalTo(self);
//    }];
//
//    /**
//     返回按钮
//     */
//    [self.backBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//        make.centerY.mas_equalTo(self.titleLabel);
//
//        make.left.mas_equalTo(self).offset(20);
//    }];
//
//    /**
//     设置按钮
//     */
//    [self.setBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//        make.centerY.mas_equalTo(self.titleLabel);
//
//        make.right.mas_equalTo(self.infoBtn.mas_left).offset(-15);
//    }];
//
//    /**
//     详情按钮
//     */
//    [self.infoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//        make.centerY.mas_equalTo(self.titleLabel);
//
//        make.right.mas_equalTo(self).offset(-20);
//    }];
    
    /**
     头像
     */
    [self.headImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(20);
        
        make.centerX.mas_equalTo(self);
        
        make.width.height.mas_equalTo(60);
    }];
    
    /**
     昵称
     */
    [self.nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.headImageView.mas_bottom).offset(10);
        
        make.right.mas_equalTo(self.headImageView.mas_centerX).offset(10);
    }];
    
    /**
     性别
     */
    [self.sexImage mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.nickNameLabel);
        
        make.left.mas_equalTo(self.nickNameLabel.mas_right).offset(5);
    }];
    
    
    /**
     年龄
     */
    [self.ageLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.headImageView.mas_left);
        
        make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(5);
    }];
    
    /**
     电话Label
     */
    [self.phoneLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.ageLabel);
        
        make.left.mas_equalTo(self.ageLabel.mas_right).offset(15);
        
    }];
    
    
    /**
     电话
     */
    [self.phoneBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        
        make.centerY.mas_equalTo(self.headImageView);
        
        make.left.mas_equalTo(self.headImageView.mas_right).offset(50);
    }];
    
    /**
     短信
     */
    [self.msgBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        
        make.centerY.mas_equalTo(self.headImageView);
        
        make.right.mas_equalTo(self.headImageView.mas_left).offset(-50);
        
    }];
    
    /**
     基本信息
     */
    [self.btn1 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
//        make.top.mas_equalTo(self.phoneLabel.mas_bottom).offset(10);
        make.bottom.mas_equalTo(self);
        make.left.mas_equalTo(self);
    }];
    
    /**
     上课记录
     */
    [self.btn2 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.btn1);
        make.left.mas_equalTo(self.btn1.mas_right);
        make.width.mas_equalTo(self.btn1);
    }];
    
    /**
     跟进记录
     */
    [self.btn3 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.btn1);
        make.left.mas_equalTo(self.btn2.mas_right);
        make.width.mas_equalTo(self.btn2);
    }];
    
    /**
     更多信息
     */
    [self.btn4 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.btn1);
        make.left.mas_equalTo(self.btn3.mas_right);
        make.right.mas_equalTo(self);
        make.width.mas_equalTo(self.btn3);
    }];
    
    [self.sanJiaoImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self);
        
        make.centerX.mas_equalTo(self.btn1);
    }];
}

@end
